﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.IO;
using System.Linq;
using System.Runtime.InteropServices;
using System.Text;
using System.Windows.Forms;
using Autodesk.Revit.DB;
using Autodesk.Revit.UI;
using YArchitech.LIB;
using YArchitech.LIB.YJKControls;
using YArchitech.Revit.RevitExtension;
using YJKArchMethodLibrary.Utils;
using YJKCodeBase.WinForm.HookSuit;
using YJKPreviewerControl;

namespace YJKDimensionModel.LevelDimension
{
	public partial class LevelDimensionForm : EscBaseForm
	{
		[DllImport("user32.dll", EntryPoint = "SendMessageA")]
		public static extern int SendMessage(IntPtr hwnd, int wMsg, IntPtr wParam, IntPtr lParam);

		[DllImport("user32.dll")]
		public static extern void keybd_event(byte bVk, byte bScan, int dwFlags, int dwExtraInfo);

		public DimensionStyle DimStyleGraph
		{
			get
			{
				return this.m_dimStyleGraph;
			}
		}

		public LevelDimensionForm(IntPtr iHandle, ExternalCommandData cmdData)
		{
			this.InitializeComponent();
			this.InitializePreviewer();
			this.m_cmdData = cmdData;
			this.m_iHandle = iHandle;
			this.m_dictFloorInfors = new Dictionary<int, List<string>>();
			this.m_lstAllLevels = new List<Level>();
		}

		public bool Automatic
		{
			get
			{
				return this.rbAutomatic.Checked;
			}
			set
			{
				this.rbAutomatic.Checked = value;
			}
		}

		public bool Manual
		{
			get
			{
				return this.rbManual.Checked;
			}
			set
			{
				this.rbManual.Checked = value;
			}
		}

		public bool Associate
		{
			get
			{
				return this.chkAssociate.Checked;
			}
			set
			{
				this.chkAssociate.Checked = value;
			}
		}

		public bool AutoAddFloorName
		{
			get
			{
				return this.chkAutoAddFloorNo.Checked;
			}
			set
			{
				this.chkAutoAddFloorNo.Checked = value;
			}
		}

		public int HeaderStyle
		{
			get
			{
				return this.cmbHeaderStyle.SelectedIndex;
			}
			set
			{
				this.cmbHeaderStyle.SelectedIndex = value;
			}
		}

		public bool InfoChange
		{
			get
			{
				return this.m_bInfoChange;
			}
			set
			{
				this.m_bInfoChange = value;
			}
		}

		public bool AddParenthesis
		{
			get
			{
				return this.chkAddParenthesis.Checked;
			}
			set
			{
				this.chkAddParenthesis.Checked = value;
			}
		}

		public DimensionStyleParameter DimensionStyleParam
		{
			get
			{
				return this.m_dimStyleParam;
			}
		}

		public Dictionary<int, List<string>> FloorInfos
		{
			get
			{
				return this.m_dictFloorInfors;
			}
		}

		public DimensionStyle DimensionStyleGraph
		{
			get
			{
				return this.m_dimStyleGraph;
			}
		}

		private void LevelDimensionForm_Load(object sender, EventArgs e)
		{
			//base.Icon = Resource.YArchitechIcon;
			this.m_lstAllLevels = this.GetSortLevels();
			this.InitializeControl();
			this.ReadData();
			this.RefreshPreview();
			this.m_hook = new MouseHook(this);
			this.m_hook.HookStart();
		}

		protected override void DefWndProc(ref Message m)
		{
			int msg = m.Msg;
			if (msg == 1125)
			{
				if (!this.m_IsDlgShow)
				{
					this.SendMess();
					return;
				}
			}
			else
			{
				base.DefWndProc(ref m);
			}
		}

		private void SendMess()
		{
			this.m_bIsLevelDlg = true;
			if (this.InfoChange)
			{
				this.SendESC();
				this.InfoChange = false;
			}
			if ((this.Manual && this.dataGridView1.Rows.Count > 1) || (this.gbMultiLayer.Visible && this.dataGridView1.Rows.Count >= 1))
			{
				this.RemoveEmptyRow();
				this.dataGridView1.CurrentCell = null;
			}
		}

		private void LevelDimensionForm_FormClosing(object sender, FormClosingEventArgs e)
		{
			this.WriteFormData();
			this.SendESC();
		}

		private void InitializePreviewer()
		{
			this.m_Previewer = new Previewer(1u);
			this.gbImageShow.Controls.Add(this.m_Previewer);
            this.m_Previewer.Location = new System.Drawing.Point(5, 11);
			this.m_Previewer.Size = new Size(245, 82);
			this.m_Previewer.SizeMode = PictureBoxSizeMode.AutoSize;
			this.m_Previewer.TabIndex = 7;
			this.m_Previewer.TabStop = false;
		}

		private void InitializeControl()
		{
			this.InitializeTable();
			this.InitializeComboBox(this.cmbHeaderStyle, this.GetHeaderStyle(), true);
			this.radioBtnOne.Checked = true;
			this.gbSingleLayer.Visible = true;
			this.gbMultiLayer.Visible = false;
			this.chkAutoAddFloorNo.Checked = true;
			this.chkAddParenthesis.Checked = true;
			this.dataGridView1.AllowUserToAddRows = false;
		}

		private void InitializeTable()
		{
			this.dataGridView1.RowHeadersVisible = false;
			this.dataGridView1.ColumnHeadersVisible = true;
			DataGridViewTextBoxColumn dataGridViewTextBoxColumn = new DataGridViewTextBoxColumn();
			dataGridViewTextBoxColumn.Name = "FloorLevel";
			dataGridViewTextBoxColumn.HeaderText = "楼层标高";
			dataGridViewTextBoxColumn.Width = 100;
			dataGridViewTextBoxColumn.SortMode = DataGridViewColumnSortMode.NotSortable;
			this.dataGridView1.Columns.Insert(0, dataGridViewTextBoxColumn);
			dataGridViewTextBoxColumn = new DataGridViewTextBoxColumn();
			dataGridViewTextBoxColumn.Name = "FloorInfo";
			dataGridViewTextBoxColumn.HeaderText = "楼层号/标高说明";
			dataGridViewTextBoxColumn.Width = 140;
			dataGridViewTextBoxColumn.SortMode = DataGridViewColumnSortMode.NotSortable;
			this.dataGridView1.Columns.Insert(1, dataGridViewTextBoxColumn);
			this.dataGridView1.Rows.Clear();
			int index = this.dataGridView1.Rows.Add();
			this.dataGridView1.Rows[index].ReadOnly = true;
		}

        private void InitializeComboBox(System.Windows.Forms.ComboBox control, List<string> typeNameList, bool bBottom = true)
		{
			control.Items.Clear();
			foreach (string item in typeNameList)
			{
				control.Items.Add(item);
			}
			if (control.Items.Count > 0)
			{
				if (bBottom)
				{
					control.SelectedIndex = 0;
					return;
				}
				control.SelectedIndex = typeNameList.Count - 1;
			}
		}

		private void RefreshPreview()
		{
			List<TextNoteInfo> textNotes = new List<TextNoteInfo>();
			List<CurveInfo> curves = new List<CurveInfo>();
			List<FillRegion> fillRegions = new List<FillRegion>();
			this.GetCurveInfos(ref curves);
			this.GetFillRegionInfos(ref fillRegions);
			this.GetTextNoteInfos(ref textNotes);
			this.m_Previewer.TextNotes = textNotes;
			this.m_Previewer.Curves = curves;
			this.m_Previewer.FillRegions = fillRegions;
			this.m_Previewer.ZoomExtents();
		}

		private void UpdateFloorInfos()
		{
			Dictionary<int, List<string>> dictionary = new Dictionary<int, List<string>>();
			foreach (KeyValuePair<int, List<string>> keyValuePair in this.m_dictFloorInfors)
			{
				int key = keyValuePair.Key;
				List<string> value = keyValuePair.Value;
				dictionary.Add(key, value);
			}
			this.m_dictFloorInfors.Clear();
			foreach (KeyValuePair<int, List<string>> keyValuePair2 in dictionary)
			{
				int key2 = keyValuePair2.Key;
				List<string> list = new List<string>();
				string text = keyValuePair2.Value.ElementAt(0);
				string text2 = keyValuePair2.Value.ElementAt(1);
				if ("" != text)
				{
					text = LevelDimensionManager.FloorLevelByPrecision(text, this.m_dimStyleParam.m_nPrecision);
				}
				list.Add(text);
				list.Add(text2);
				this.m_dictFloorInfors.Add(key2, list);
				this.dataGridView1.Rows[key2].Cells[0].Value = text;
				this.dataGridView1.Rows[key2].Cells[1].Value = text2;
			}
		}

		private void ReadData()
		{
			this.ReadFormData();
			this.ReadTextSetData();
		}

		private void ReadTextSetData()
		{
			string userDataLocation = Product.UserDataLocation;
			string path = userDataLocation + "LevelStyleForm.dat";
			if (!File.Exists(path))
			{
				this.m_dimStyleParam.m_strTextFont = "黑体 4mm";
				this.m_dimStyleParam.m_dTextHeight = 3.5;
				this.m_dimStyleParam.m_dAspectRatio = 0.7;
				this.m_dimStyleParam.m_nPrecision = 1;
				this.m_dimStyleParam.m_nTextAlign = 2;
				return;
			}
			FileStream fileStream = new FileStream(path, FileMode.Open);
			StreamReader streamReader = new StreamReader(fileStream);
			streamReader.BaseStream.Seek(0L, SeekOrigin.Begin);
			this.m_dimStyleParam.m_strTextFont = streamReader.ReadLine();
			this.m_dimStyleParam.m_dTextHeight = LevelDimensionManager.StrToDouble(streamReader.ReadLine(), 0.0);
			this.m_dimStyleParam.m_dAspectRatio = LevelDimensionManager.StrToDouble(streamReader.ReadLine(), 0.0);
			this.m_dimStyleParam.m_nPrecision = LevelDimensionManager.StrToInt(streamReader.ReadLine(), 0);
			this.m_dimStyleParam.m_nTextAlign = LevelDimensionManager.StrToInt(streamReader.ReadLine(), 0);
			streamReader.Close();
			fileStream.Close();
		}

		private void ReadFormData()
		{
			string tempPath = Path.GetTempPath();
			string path = tempPath + "LevelDimension.dat";
			if (!File.Exists(path))
			{
				return;
			}
			FileStream fileStream = new FileStream(path, FileMode.Open);
			StreamReader streamReader = new StreamReader(fileStream);
			streamReader.BaseStream.Seek(0L, SeekOrigin.Begin);
			int x = 0;
			int y = 0;
			try
			{
				x = Convert.ToInt32(streamReader.ReadLine());
				y = Convert.ToInt32(streamReader.ReadLine());
			}
			catch
			{
				x = 0;
				y = 0;
			}
			streamReader.Close();
			fileStream.Close();
            System.Drawing.Point location = new System.Drawing.Point(x, y);
			base.Location = location;
		}

		private void WriteFormData()
		{
			string tempPath = Path.GetTempPath();
			string path = tempPath + "LevelDimension.dat";
			FileStream fileStream = new FileStream(path, FileMode.Create);
			StreamWriter streamWriter = new StreamWriter(fileStream);
			streamWriter.WriteLine(base.Location.X);
			streamWriter.WriteLine(base.Location.Y);
			streamWriter.Flush();
			streamWriter.Close();
			fileStream.Close();
		}

		private List<string> GetHeaderStyle()
		{
			return new List<string>
			{
				"上标头",
				"下标头"
			};
		}

		private List<string> GetAllLevelNames()
		{
			List<string> list = new List<string>();
			foreach (Element element in this.m_lstAllLevels)
			{
				if (!list.Contains(element.Name))
				{
					list.Add(element.Name);
				}
			}
			return list;
		}

		private List<Level> GetSortLevels()
		{
			double minValue = double.MinValue;
			double maxValue = double.MaxValue;
			List<Level> list = new List<Level>();
			FilteredElementCollector filteredElementCollector = new FilteredElementCollector(this.m_cmdData.Application.ActiveUIDocument.Document);
			ICollection<Element> collection = filteredElementCollector.OfClass(typeof(Level)).ToElements();
			foreach (Element element in collection)
			{
				Level level = element as Level;
				double elevation = level.Elevation;
				if (elevation >= minValue && elevation <= maxValue)
				{
					list.Add(level);
				}
			}
			list.Sort(new LevelComparer());
			return list;
		}

		private void SetTableDataByFloor()
		{
			int selectedIndex = this.cmbStartFloor.SelectedIndex;
			int selectedIndex2 = this.cmbEndFloor.SelectedIndex;
			this.m_lstTableLevels = new List<Level>();
			for (int i = selectedIndex; i <= selectedIndex2; i++)
			{
				this.m_lstTableLevels.Add(this.m_lstAllLevels.ElementAt(i));
			}
			string item = "";
			List<string> list = new List<string>();
			bool flag = false;
			if (this.dataGridView1.Rows.Count == 0)
			{
				flag = true;
			}
			foreach (Level level in this.m_lstTableLevels)
			{
				list.Clear();
				string text = (Common.FeetToMM(level.Elevation) / 1000.0).ToString();
				text = LevelDimensionManager.FloorLevelByPrecision(text, this.m_dimStyleParam.m_nPrecision);
				if (!flag)
				{
					int index = this.dataGridView1.Rows.Count - 1;
					object value = this.dataGridView1.Rows[index].Cells[0].Value;
					object value2 = this.dataGridView1.Rows[index].Cells[1].Value;
					if ((value == null && value2 == null) || ("" == value.ToString() && "" == value2.ToString()))
					{
						this.dataGridView1.Rows[index].Cells[0].Value = text;
						if (this.chkAutoAddFloorNo.Checked)
						{
							this.dataGridView1.Rows[index].Cells[1].Value = level.Name;
							continue;
						}
						continue;
					}
				}
				int index2 = this.dataGridView1.Rows.Add();
				this.dataGridView1.Rows[index2].Cells[0].Value = text;
				if (this.chkAutoAddFloorNo.Checked)
				{
					this.dataGridView1.Rows[index2].Cells[1].Value = level.Name;
					item = LevelDimensionManager.FloorInforAddParenthesis(level.Name, this.chkAddParenthesis.Checked);
				}
				list.Add(text);
				list.Add(item);
				flag = false;
			}
		}

		public void SendESC()
		{
			byte bVk = 27;
			int dwFlags = 0;
			int dwFlags2 = 2;
			int wMsg = 7;
			LevelDimensionForm.SendMessage(this.m_iHandle, wMsg, IntPtr.Zero, IntPtr.Zero);
			LevelDimensionForm.keybd_event(bVk, 0, dwFlags, 0);
			LevelDimensionForm.keybd_event(bVk, 0, dwFlags2, 0);
		}

		private void GetCurveInfos(ref List<CurveInfo> lstCurveInfos)
		{
			switch (this.m_dimStyleGraph)
			{
			case DimensionStyle.DS_ONE:
				this.PreviewStyleOne(ref lstCurveInfos);
				return;
			case DimensionStyle.DS_TWO:
				this.PreviewStyleTwo(ref lstCurveInfos);
				return;
			case DimensionStyle.DS_THREE:
				this.PreviewStyleThree(ref lstCurveInfos);
				return;
			case DimensionStyle.DS_FOUR:
				this.PreviewStyleFour(ref lstCurveInfos);
				break;
			case DimensionStyle.DS_FIVE:
			case DimensionStyle.DS_SIX:
				break;
			default:
				return;
			}
		}

		private void PreviewStyleOne(ref List<CurveInfo> lstCurveInfos)
		{
			XYZ xyz = new XYZ(3.0, 0.0, 0.0);
			XYZ xyz2 = new XYZ(0.0, 3.0, 0.0);
			if (1 == this.HeaderStyle)
			{
				xyz2 = -xyz2;
			}
			XYZ zero = XYZ.Zero;
			XYZ xyz3 = zero - xyz + xyz2;
			XYZ xyz4 = xyz3 + 2.0 * xyz;
			XYZ xyz5 = xyz4 + 3.0 * xyz;
			CurveInfo item = new CurveInfo(YJKLineEx.YJKGetBound(zero, xyz3), PenColor.PC_Black, 1f);
			CurveInfo item2 = new CurveInfo(YJKLineEx.YJKGetBound(zero, xyz4), PenColor.PC_Black, 1f);
			CurveInfo item3 = new CurveInfo(YJKLineEx.YJKGetBound(xyz3, xyz5), PenColor.PC_Black, 1f);
			lstCurveInfos.Add(item);
			lstCurveInfos.Add(item2);
			lstCurveInfos.Add(item3);
			this.m_ptLeft = xyz3;
			this.m_ptRight = xyz5;
		}

		private void PreviewStyleTwo(ref List<CurveInfo> lstCurveInfos)
		{
			XYZ xyz = new XYZ(1.0, 0.0, 0.0);
			XYZ xyz2 = new XYZ(0.0, 1.0, 0.0);
			if (1 == this.HeaderStyle)
			{
				xyz2 = -xyz2;
			}
			XYZ zero = XYZ.Zero;
			XYZ xyz3 = zero - xyz + xyz2;
			XYZ xyz4 = xyz3 + 2.0 * xyz;
			XYZ xyz5 = xyz4 + 3.0 * xyz;
			XYZ startPoint = zero - 2.0 * xyz;
			XYZ endPoint = zero + xyz;
			CurveInfo item = new CurveInfo(YJKLineEx.YJKGetBound(zero, xyz3), PenColor.PC_Black, 1f);
			CurveInfo item2 = new CurveInfo(YJKLineEx.YJKGetBound(zero, xyz4), PenColor.PC_Black, 1f);
			CurveInfo item3 = new CurveInfo(YJKLineEx.YJKGetBound(xyz3, xyz5), PenColor.PC_Black, 1f);
			CurveInfo item4 = new CurveInfo(YJKLineEx.YJKGetBound(startPoint, endPoint), PenColor.PC_Black, 1f);
			lstCurveInfos.Add(item);
			lstCurveInfos.Add(item2);
			lstCurveInfos.Add(item3);
			lstCurveInfos.Add(item4);
			this.m_ptLeft = xyz3;
			this.m_ptRight = xyz5;
		}

		private void PreviewStyleThree(ref List<CurveInfo> lstCurveInfos)
		{
			XYZ xyz = new XYZ(1.0, 0.0, 0.0);
			XYZ xyz2 = new XYZ(0.0, 1.0, 0.0);
			if (1 == this.HeaderStyle)
			{
				xyz2 = -xyz2;
			}
			XYZ zero = XYZ.Zero;
			XYZ xyz3 = zero - xyz + xyz2;
			XYZ endPoint = xyz3 + 2.0 * xyz;
			XYZ xyz4 = zero + 2.0 * xyz2;
			XYZ xyz5 = xyz4 + 6.0 * xyz;
			CurveInfo item = new CurveInfo(YJKLineEx.YJKGetBound(zero, xyz3), PenColor.PC_Black, 1f);
			CurveInfo item2 = new CurveInfo(YJKLineEx.YJKGetBound(zero, endPoint), PenColor.PC_Black, 1f);
			CurveInfo item3 = new CurveInfo(YJKLineEx.YJKGetBound(xyz3, endPoint), PenColor.PC_Black, 1f);
			CurveInfo item4 = new CurveInfo(YJKLineEx.YJKGetBound(zero, xyz4), PenColor.PC_Black, 1f);
			CurveInfo item5 = new CurveInfo(YJKLineEx.YJKGetBound(xyz4, xyz5), PenColor.PC_Black, 1f);
			lstCurveInfos.Add(item);
			lstCurveInfos.Add(item2);
			lstCurveInfos.Add(item3);
			lstCurveInfos.Add(item4);
			lstCurveInfos.Add(item5);
			this.m_ptLeft = xyz4;
			this.m_ptRight = xyz5;
		}

		private void PreviewStyleFour(ref List<CurveInfo> lstCurveInfos)
		{
			XYZ xyz = new XYZ(3.0, 0.0, 0.0);
			XYZ xyz2 = new XYZ(0.0, 3.0, 0.0);
			if (1 == this.HeaderStyle)
			{
				xyz2 = -xyz2;
			}
			XYZ zero = XYZ.Zero;
			XYZ xyz3 = zero - xyz + xyz2;
			XYZ endPoint = xyz3 + 2.0 * xyz;
			XYZ xyz4 = zero + 2.0 * xyz2;
			XYZ xyz5 = xyz4 + 6.0 * xyz;
			XYZ startPoint = zero - 2.0 * xyz;
			XYZ endPoint2 = zero + xyz;
			CurveInfo item = new CurveInfo(YJKLineEx.YJKGetBound(zero, xyz3), PenColor.PC_Black, 1f);
			CurveInfo item2 = new CurveInfo(YJKLineEx.YJKGetBound(zero, endPoint), PenColor.PC_Black, 1f);
			CurveInfo item3 = new CurveInfo(YJKLineEx.YJKGetBound(xyz3, endPoint), PenColor.PC_Black, 1f);
			CurveInfo item4 = new CurveInfo(YJKLineEx.YJKGetBound(zero, xyz4), PenColor.PC_Black, 1f);
			CurveInfo item5 = new CurveInfo(YJKLineEx.YJKGetBound(xyz4, xyz5), PenColor.PC_Black, 1f);
			CurveInfo item6 = new CurveInfo(YJKLineEx.YJKGetBound(startPoint, endPoint2), PenColor.PC_Black, 1f);
			lstCurveInfos.Add(item);
			lstCurveInfos.Add(item2);
			lstCurveInfos.Add(item3);
			lstCurveInfos.Add(item4);
			lstCurveInfos.Add(item5);
			lstCurveInfos.Add(item6);
			this.m_ptLeft = xyz4;
			this.m_ptRight = xyz5;
		}

		private void PreviewStyleFive(ref List<CurveInfo> lstCurveInfos)
		{
			XYZ xyz = new XYZ(3.0, 0.0, 0.0);
			XYZ xyz2 = new XYZ(0.0, 3.0, 0.0);
			if (1 == this.HeaderStyle)
			{
				xyz2 = -xyz2;
			}
			XYZ zero = XYZ.Zero;
			XYZ xyz3 = zero - xyz + xyz2;
			XYZ xyz4 = xyz3 + 2.0 * xyz;
			CurveInfo item = new CurveInfo(YJKLineEx.YJKGetBound(zero, xyz3), PenColor.PC_Black, 1f);
			CurveInfo item2 = new CurveInfo(YJKLineEx.YJKGetBound(xyz3, xyz4), PenColor.PC_Black, 1f);
			CurveInfo item3 = new CurveInfo(YJKLineEx.YJKGetBound(xyz4, zero), PenColor.PC_Black, 1f);
			lstCurveInfos.Add(item);
			lstCurveInfos.Add(item2);
			lstCurveInfos.Add(item3);
			this.m_ptLeft = xyz3;
			this.m_ptRight = xyz4;
		}

		private void PreviewStyleSix(ref List<CurveInfo> lstCurveInfos)
		{
			XYZ xyz = new XYZ(1.5, 0.0, 0.0);
			XYZ xyz2 = new XYZ(0.0, 1.5, 0.0);
			XYZ xyz3 = XYZ.Zero - xyz;
			XYZ xyz4 = XYZ.Zero + xyz;
			XYZ xyz5 = XYZ.Zero + xyz2;
			XYZ xyz6 = XYZ.Zero - xyz2;
			Arc curve = Arc.Create(xyz3, xyz4, xyz5);
			Arc curve2 = Arc.Create(xyz3, xyz4, xyz6);
			CurveInfo item = new CurveInfo(curve, PenColor.PC_Black, 1f);
			CurveInfo item2 = new CurveInfo(curve2, PenColor.PC_Black, 1f);
			lstCurveInfos.Add(item);
			lstCurveInfos.Add(item2);
			this.m_ptLeft = XYZ.Zero - xyz + xyz2;
			this.m_ptRight = XYZ.Zero + xyz + xyz2;
		}

		private void GetTextNoteInfos(ref List<TextNoteInfo> lstTextNoteInfos)
		{
			XYZ xyz = new XYZ(0.0, 1.0, 0.0);
			XYZ xyz2 = new XYZ(0.0, 5.0, 0.0);
			if (1 == this.HeaderStyle)
			{
				xyz2 = -xyz2;
				xyz = -xyz + xyz2;
			}
			if (this.m_dictFloorInfors.Values.Count == 0)
			{
				return;
			}
			XYZ xyz3 = new XYZ(0.0, 0.0, 0.0);
			foreach (List<string> source in this.m_dictFloorInfors.Values)
			{
				string strText = LevelDimensionManager.FloorLevelByPrecision(source.ElementAt(0), this.m_dimStyleParam.m_nPrecision);
				string text = LevelDimensionManager.FloorInforAddParenthesis(source.ElementAt(1), this.AddParenthesis);
				string text2 = LevelDimensionManager.FloorLevelAddPrefix(strText);
				this.SetDimensionText(text2);
				this.GetOneTextInsert();
				XYZ pos = xyz + this.m_ptFloorLevelInsert + xyz3;
				XYZ pos2 = xyz + this.m_ptFloorNameInsert + xyz3;
				TextNoteInfo.AlignHType alignHType;
				if (this.m_dimStyleParam.m_nTextAlign == 0)
				{
					alignHType = TextNoteInfo.AlignHType.AHT_Left;
				}
				else if (this.m_dimStyleParam.m_nTextAlign == 1)
				{
					alignHType = TextNoteInfo.AlignHType.AHT_Center;
				}
				else
				{
					alignHType = TextNoteInfo.AlignHType.AHT_Right;
				}
				TextNoteInfo item = new TextNoteInfo(text2, PenColor.PC_Black, 3.5, pos, alignHType, TextNoteInfo.AlignVType.AVT_Bottom, (double)(5 * this.GetFloorLevelLength(text2)), 5.0);
				lstTextNoteInfos.Add(item);
				item = new TextNoteInfo(text, PenColor.PC_Black, 3.5, pos2, TextNoteInfo.AlignHType.AHT_Left, TextNoteInfo.AlignVType.AVT_Bottom, (double)(5 * this.GetFloorNameLength(text)), 5.0);
				lstTextNoteInfos.Add(item);
				xyz3 += xyz2;
			}
		}

		private void GetFillRegionInfos(ref List<FillRegion> lstFillRegions)
		{
			List<CurveInfo> lstCurveInfos = new List<CurveInfo>();
			switch (this.m_dimStyleGraph)
			{
			case DimensionStyle.DS_ONE:
			case DimensionStyle.DS_TWO:
			case DimensionStyle.DS_THREE:
			case DimensionStyle.DS_FOUR:
				break;
			case DimensionStyle.DS_FIVE:
				this.PreviewStyleFive(ref lstCurveInfos);
				this.CreateFillRegionsByLoop(ref lstFillRegions, lstCurveInfos);
				return;
			case DimensionStyle.DS_SIX:
				this.PreviewStyleSix(ref lstCurveInfos);
				this.CreateFillRegionsByLoop(ref lstFillRegions, lstCurveInfos);
				break;
			default:
				return;
			}
		}

		private void CreateFillRegionsByLoop(ref List<FillRegion> lstFillRegions, List<CurveInfo> lstCurveInfos)
		{
			List<Curve> list = new List<Curve>();
			foreach (CurveInfo curveInfo in lstCurveInfos)
			{
				list.Add(curveInfo.CurveObj);
			}
			FillRegion item = new FillRegion(list, PenColor.PC_Black);
			lstFillRegions.Add(item);
		}

		private int GetFloorNameLength(string strFloorName)
		{
			if (strFloorName.Length == 0)
			{
				return 0;
			}
			ASCIIEncoding asciiencoding = new ASCIIEncoding();
			int num = 0;
			byte[] bytes = asciiencoding.GetBytes(strFloorName);
			for (int i = 0; i < bytes.Length; i++)
			{
				if (bytes[i] == 63)
				{
					num += 2;
				}
				else
				{
					num++;
				}
			}
			return num;
		}

		private int GetFloorLevelLength(string strFloorLevel)
		{
			return strFloorLevel.Length;
		}

		private TextNoteInfo.AlignHType GetTextAlignHType()
		{
			TextNoteInfo.AlignHType result = TextNoteInfo.AlignHType.AHT_Left;
			if (this.m_dimStyleParam.m_nTextAlign == 0 || 1 == this.m_dimStyleParam.m_nTextAlign || DimensionStyle.DS_FIVE == this.m_dimStyleGraph || DimensionStyle.DS_SIX == this.m_dimStyleGraph)
			{
				result = TextNoteInfo.AlignHType.AHT_Left;
			}
			else if (2 == this.m_dimStyleParam.m_nTextAlign)
			{
				result = TextNoteInfo.AlignHType.AHT_Right;
			}
			return result;
		}

		private void GetTwoTextInsert()
		{
			double dTextLength = (double)this.GetFloorNameLength(this.m_strDimensionText) * 2.4;
			this.GetInsertPointByRightAligh(dTextLength);
		}

		private void GetOneTextInsert()
		{
			double dTextLength = (double)this.GetFloorNameLength(this.m_strDimensionText) * 2.4;
			if (this.m_dimStyleParam.m_nTextAlign == 0)
			{
				this.m_ptFloorLevelInsert = this.m_ptLeft;
				this.GetInsertPointByLeftAlign(dTextLength);
				return;
			}
			if (1 == this.m_dimStyleParam.m_nTextAlign)
			{
				this.GetInsertPointByCenterAlign(dTextLength);
				return;
			}
			this.GetInsertPointByRightAligh(dTextLength);
		}

		private void GetInsertPointByLeftAlign(double dTextLength)
		{
			switch (this.m_dimStyleGraph)
			{
			case DimensionStyle.DS_ONE:
			case DimensionStyle.DS_TWO:
				this.GetFloorNameInsertPoint(15.0, dTextLength);
				return;
			case DimensionStyle.DS_THREE:
			case DimensionStyle.DS_FOUR:
				this.GetFloorNameInsertPoint(12.0, dTextLength);
				return;
			case DimensionStyle.DS_FIVE:
				this.GetLevelAndNameInsertPoint(6.0, dTextLength);
				return;
			case DimensionStyle.DS_SIX:
				this.GetLevelAndNameInsertPoint(2.0, dTextLength);
				return;
			default:
				return;
			}
		}

		private void GetInsertPointByCenterAlign(double dTextLength)
		{
			switch (this.m_dimStyleGraph)
			{
			case DimensionStyle.DS_ONE:
			case DimensionStyle.DS_TWO:
				this.GetLevelAndNameInsertPoint(15.0, dTextLength);
				return;
			case DimensionStyle.DS_THREE:
			case DimensionStyle.DS_FOUR:
				this.GetLevelAndNameInsertPoint(12.0, dTextLength);
				return;
			case DimensionStyle.DS_FIVE:
				this.GetLevelAndNameInsertPoint(6.0, dTextLength);
				return;
			case DimensionStyle.DS_SIX:
				this.GetLevelAndNameInsertPoint(2.0, dTextLength);
				return;
			default:
				return;
			}
		}

		private void GetInsertPointByRightAligh(double dTextLength)
		{
			switch (this.m_dimStyleGraph)
			{
			case DimensionStyle.DS_ONE:
			case DimensionStyle.DS_TWO:
			case DimensionStyle.DS_THREE:
			case DimensionStyle.DS_FOUR:
				this.m_ptFloorLevelInsert = this.m_ptRight;
				this.m_ptFloorNameInsert = this.m_ptRight;
				return;
			case DimensionStyle.DS_FIVE:
				this.GetLevelAndNameInsertPoint(6.0, dTextLength);
				return;
			case DimensionStyle.DS_SIX:
				this.GetLevelAndNameInsertPoint(2.0, dTextLength);
				return;
			default:
				return;
			}
		}

		private void GetLevelAndNameInsertPoint(double dDimensionLength, double dTextLength)
		{
			double num = dDimensionLength - dTextLength;
			XYZ xyz = new XYZ(num / 2.0, 0.0, 0.0);
			this.m_ptFloorLevelInsert = this.m_ptLeft + xyz;
			this.m_ptFloorNameInsert = this.m_ptFloorLevelInsert + new XYZ(dTextLength, 0.0, 0.0);
		}

		private void GetFloorNameInsertPoint(double dDimensionLength, double dTextLength)
		{
			double num = dDimensionLength - dTextLength;
			if (0.0 <= num)
			{
				this.m_ptFloorNameInsert = this.m_ptRight;
				return;
			}
			this.m_ptFloorNameInsert = this.m_ptFloorLevelInsert + new XYZ(dTextLength, 0.0, 0.0);
		}

		private void SetDimensionText(string strText)
		{
			this.m_strDimensionText = strText;
		}

		private void RemoveEmptyRow()
		{
			this.dataGridView1.AllowUserToAddRows = false;
			if (1 < this.dataGridView1.Rows.Count)
			{
				for (int i = 0; i < this.dataGridView1.Rows.Count; i++)
				{
					object value = this.dataGridView1.Rows[i].Cells[0].Value;
					object value2 = this.dataGridView1.Rows[i].Cells[1].Value;
					if (value == null && value2 == null)
					{
						this.dataGridView1.Rows.RemoveAt(i);
						i--;
					}
					else
					{
						string b = "null";
						string b2 = "null";
						if (value != null)
						{
							b = value.ToString();
						}
						if (value2 != null)
						{
							b2 = value2.ToString();
						}
						if ("" == b && "" == b2)
						{
							this.dataGridView1.Rows.RemoveAt(i);
							i--;
						}
					}
				}
				if (this.dataGridView1.Rows.Count == 0)
				{
					int index = this.dataGridView1.Rows.Add();
					this.dataGridView1.Rows[index].ReadOnly = false;
				}
			}
		}

		private void radioBtnOne_Click(object sender, EventArgs e)
		{
			this.radioBtnOne.Checked = true;
			this.radioBtnTwo.Checked = false;
			this.radioBtnThree.Checked = false;
			this.radioBtnFour.Checked = false;
			this.radioBtnFive.Checked = false;
			this.radioBtnSix.Checked = false;
			this.m_dimStyleGraph = DimensionStyle.DS_ONE;
			this.RefreshPreview();
		}

		private void radioBtnTwo_Click(object sender, EventArgs e)
		{
			this.radioBtnOne.Checked = false;
			this.radioBtnTwo.Checked = true;
			this.radioBtnThree.Checked = false;
			this.radioBtnFour.Checked = false;
			this.radioBtnFive.Checked = false;
			this.radioBtnSix.Checked = false;
			this.m_dimStyleGraph = DimensionStyle.DS_TWO;
			this.RefreshPreview();
		}

		private void radioBtnThree_Click(object sender, EventArgs e)
		{
			this.radioBtnOne.Checked = false;
			this.radioBtnTwo.Checked = false;
			this.radioBtnThree.Checked = true;
			this.radioBtnFour.Checked = false;
			this.radioBtnFive.Checked = false;
			this.radioBtnSix.Checked = false;
			this.m_dimStyleGraph = DimensionStyle.DS_THREE;
			this.RefreshPreview();
		}

		private void radioBtnFour_Click(object sender, EventArgs e)
		{
			this.radioBtnOne.Checked = false;
			this.radioBtnTwo.Checked = false;
			this.radioBtnThree.Checked = false;
			this.radioBtnFour.Checked = true;
			this.radioBtnFive.Checked = false;
			this.radioBtnSix.Checked = false;
			this.m_dimStyleGraph = DimensionStyle.DS_FOUR;
			this.RefreshPreview();
		}

		private void radioBtnFive_Click(object sender, EventArgs e)
		{
			this.radioBtnOne.Checked = false;
			this.radioBtnTwo.Checked = false;
			this.radioBtnThree.Checked = false;
			this.radioBtnFour.Checked = false;
			this.radioBtnFive.Checked = true;
			this.radioBtnSix.Checked = false;
			this.m_dimStyleGraph = DimensionStyle.DS_FIVE;
			this.RefreshPreview();
		}

		private void radioBtnSix_Click(object sender, EventArgs e)
		{
			this.radioBtnOne.Checked = false;
			this.radioBtnTwo.Checked = false;
			this.radioBtnThree.Checked = false;
			this.radioBtnFour.Checked = false;
			this.radioBtnFive.Checked = false;
			this.radioBtnSix.Checked = true;
			this.m_dimStyleGraph = DimensionStyle.DS_SIX;
			this.RefreshPreview();
		}

		private void btnSet_Click(object sender, EventArgs e)
		{
			this.m_IsDlgShow = true;
			LevelStyleForm levelStyleForm = new LevelStyleForm(this.m_cmdData, this);
			if (DialogResult.OK == levelStyleForm.ShowDialog())
			{
				this.m_dimStyleParam = levelStyleForm.GetDimensionStyleParam();
			}
			this.m_IsDlgShow = false;
			base.Show();
			this.RefreshPreview();
			this.UpdateFloorInfos();
		}

		private void btnMultiLevel_Click(object sender, EventArgs e)
		{
			this.gbSingleLayer.Visible = false;
			this.gbMultiLayer.Visible = true;
			this.rbManual.Checked = false;
			this.rbAutomatic.Checked = false;
			this.chkAssociate.Checked = false;
			this.chkAutoAddFloorNo.Text = "自动添楼层号到标高表格";
			this.chkAutoAddFloorNo.Checked = true;
			this.chkAutoAddFloorNo.Enabled = true;
			this.chkAddParenthesis.Checked = true;
			this.dataGridView1.AllowUserToAddRows = false;
			this.dataGridView1.Rows.Clear();
			int index = this.dataGridView1.Rows.Add();
			this.dataGridView1.Rows[index].ReadOnly = false;
			this.m_dictFloorInfors = new Dictionary<int, List<string>>();
			this.InitializeComboBox(this.cmbStartFloor, this.GetAllLevelNames(), true);
			this.InitializeComboBox(this.cmbEndFloor, this.GetAllLevelNames(), false);
			this.RefreshPreview();
		}

		private void btnSingleLevel_Click(object sender, EventArgs e)
		{
			this.gbSingleLayer.Visible = true;
			this.gbMultiLayer.Visible = false;
			this.dataGridView1.Rows.Clear();
			int index = this.dataGridView1.Rows.Add();
			this.dataGridView1.Rows[index].ReadOnly = true;
			this.m_dictFloorInfors = new Dictionary<int, List<string>>();
			this.rbAutomatic.Checked = true;
			this.rbManual.Checked = false;
			this.chkAssociate.Checked = false;
			this.chkAutoAddFloorNo.Text = "自动添加楼层号";
			this.chkAutoAddFloorNo.Checked = true;
			this.chkAutoAddFloorNo.Enabled = true;
			this.chkAddParenthesis.Checked = true;
			this.dataGridView1.AllowUserToAddRows = false;
			this.RefreshPreview();
		}

		private void btnAddFloors_Click(object sender, EventArgs e)
		{
			this.SetTableDataByFloor();
			this.RefreshPreview();
		}

		private void btnDeleteFloors_Click(object sender, EventArgs e)
		{
			this.dataGridView1.Rows.Clear();
			int index = this.dataGridView1.Rows.Add();
			this.dataGridView1.Rows[index].ReadOnly = false;
			this.m_dictFloorInfors = new Dictionary<int, List<string>>();
			this.RefreshPreview();
		}

		private void btnClose_Click(object sender, EventArgs e)
		{
			this.SendESC();
		}

		private void rbAutomatic_CheckedChanged(object sender, EventArgs e)
		{
			this.dataGridView1.Rows.Clear();
			int index = this.dataGridView1.Rows.Add();
			this.dataGridView1.Rows[index].ReadOnly = true;
			this.chkAssociate.Checked = false;
			this.chkAssociate.Enabled = true;
			this.chkAutoAddFloorNo.Checked = false;
			this.chkAutoAddFloorNo.Enabled = true;
			this.dataGridView1.AllowUserToAddRows = false;
			this.m_dictFloorInfors = new Dictionary<int, List<string>>();
			this.RefreshPreview();
		}

		private void rbManual_CheckedChanged(object sender, EventArgs e)
		{
			this.dataGridView1.Rows.Clear();
			this.chkAssociate.Checked = false;
			this.chkAssociate.Enabled = false;
			this.chkAutoAddFloorNo.Checked = false;
			this.chkAutoAddFloorNo.Enabled = false;
			this.chkAddParenthesis.Enabled = true;
			this.dataGridView1.AllowUserToAddRows = true;
			this.m_dictFloorInfors = new Dictionary<int, List<string>>();
			this.RefreshPreview();
		}

		private void chkAddParenthesis_CheckedChanged(object sender, EventArgs e)
		{
			this.RefreshPreview();
		}

		private void chkAssociate_CheckedChanged(object sender, EventArgs e)
		{
			if (this.chkAssociate.Checked)
			{
				this.chkAutoAddFloorNo.Checked = false;
				this.chkAutoAddFloorNo.Enabled = false;
				this.chkAddParenthesis.Checked = false;
				this.chkAddParenthesis.Enabled = false;
			}
			else
			{
				this.chkAutoAddFloorNo.Checked = false;
				this.chkAutoAddFloorNo.Enabled = true;
				this.chkAddParenthesis.Checked = false;
				this.chkAddParenthesis.Enabled = true;
			}
			this.RefreshPreview();
		}

		private void cmbStartFloor_SelectedIndexChanged(object sender, EventArgs e)
		{
		}

		private void cmbEndFloor_SelectedIndexChanged(object sender, EventArgs e)
		{
		}

		private void cmbHeaderStyle_SelectedIndexChanged(object sender, EventArgs e)
		{
			this.RefreshPreview();
		}

		private void LevelDimensionForm_MouseLeave(object sender, EventArgs e)
		{
		}

		private void dataGridView1_KeyDown(object sender, KeyEventArgs e)
		{
			if (Keys.Return == e.KeyCode)
			{
				int index = this.dataGridView1.CurrentRow.Index;
				DataGridViewRow dataGridViewRow = new DataGridViewRow();
				dataGridViewRow.CreateCells(this.dataGridView1);
				dataGridViewRow.Cells[0].Value = "";
				dataGridViewRow.Cells[1].Value = "";
				this.dataGridView1.Rows.Insert(index + 1, dataGridViewRow);
				this.dataGridView1.Rows[index + 1].Selected = true;
				this.RefreshPreview();
			}
		}

		private void cmbStartFloor_Validating(object sender, CancelEventArgs e)
		{
			if (this.cmbStartFloor.SelectedIndex > this.cmbEndFloor.SelectedIndex)
			{
				MessageBox.Show("起始层不能高于结束层.", "警告", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
				e.Cancel = true;
			}
		}

		private void cmbEndFloor_Validating(object sender, CancelEventArgs e)
		{
			if (this.cmbStartFloor.SelectedIndex > this.cmbEndFloor.SelectedIndex)
			{
				MessageBox.Show("结束层不能低于起始层.", "警告", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
				e.Cancel = true;
			}
		}

		private void dataGridView1_CellValueChanged(object sender, DataGridViewCellEventArgs e)
		{
			if (e.RowIndex < 0)
			{
				return;
			}
			List<string> list = new List<string>();
			object value = this.dataGridView1.Rows[e.RowIndex].Cells[0].Value;
			object value2 = this.dataGridView1.Rows[e.RowIndex].Cells[1].Value;
			if (value != null)
			{
				list.Add(LevelDimensionManager.FloorLevelAddPrefix(value.ToString()));
			}
			else
			{
				list.Add("");
			}
			if (value2 != null)
			{
				list.Add(value2.ToString());
			}
			else
			{
				list.Add("");
			}
			if (this.m_dictFloorInfors.Keys.Contains(e.RowIndex))
			{
				using (Dictionary<int, List<string>>.KeyCollection.Enumerator enumerator = this.m_dictFloorInfors.Keys.GetEnumerator())
				{
					while (enumerator.MoveNext())
					{
						int num = enumerator.Current;
						if (num == e.RowIndex)
						{
							this.m_dictFloorInfors.Remove(num);
							if ("" != list.ElementAt(0) || "" != list.ElementAt(1))
							{
								this.m_dictFloorInfors.Add(num, list);
								break;
							}
							break;
						}
					}
					goto IL_148;
				}
			}
			this.m_dictFloorInfors.Add(e.RowIndex, list);
			IL_148:
			this.RefreshPreview();
		}

		private void dataGridView1_RowsRemoved(object sender, DataGridViewRowsRemovedEventArgs e)
		{
			if (0 >= this.dataGridView1.Rows.Count)
			{
				this.m_dictFloorInfors.Clear();
				this.RefreshPreview();
				return;
			}
			if (this.m_dictFloorInfors.Keys.Contains(e.RowIndex))
			{
				foreach (int num in this.m_dictFloorInfors.Keys)
				{
					if (num == e.RowIndex)
					{
						this.m_dictFloorInfors.Remove(num);
						for (int i = num; i < this.m_dictFloorInfors.Keys.Count; i++)
						{
							int key = this.m_dictFloorInfors.Keys.ElementAt(i);
							List<string> value = this.m_dictFloorInfors.Values.ElementAt(i);
							this.m_dictFloorInfors.Remove(key);
							this.m_dictFloorInfors.Add(i, value);
						}
						break;
					}
				}
			}
			this.RefreshPreview();
		}

		private void dataGridView1_EditingControlShowing(object sender, DataGridViewEditingControlShowingEventArgs e)
		{
			if (this.dataGridView1.CurrentCell.ColumnIndex == 0)
			{
				this.EditingControl = (DataGridViewTextBoxEditingControl)e.Control;
				this.EditingControl.KeyPress += this.EditingControl_KeyPress;
				this.EditingControl.TextChanged += this.EditingControl_TextChanged;
			}
		}

		private void dataGridView1_CellBeginEdit(object sender, DataGridViewCellCancelEventArgs e)
		{
			if (e.ColumnIndex == 0)
			{
                System.Windows.Forms.TextBox textBox = new System.Windows.Forms.TextBox();
				if (this.dataGridView1.Rows[e.RowIndex].Cells[e.ColumnIndex].Value == null)
				{
					textBox.Text = "";
				}
				else
				{
					textBox.Text = this.dataGridView1.Rows[e.RowIndex].Cells[e.ColumnIndex].Value.ToString();
				}
				this.NotePastText(textBox, ref this.structPastText);
			}
		}

		private void EditingControl_TextChanged(object sender, EventArgs e)
		{
			if (this.IsNumeric(this.EditingControl.Text, true, true))
			{
				this.NotePastText(this.EditingControl, ref this.structPastText);
				return;
			}
			this.RestoreText(this.EditingControl, this.structPastText);
		}

		private void EditingControl_KeyPress(object sender, KeyPressEventArgs e)
		{
			this.CheckKeyIn(e, true);
		}

		private bool IsNumeric(string strNumber, bool bIsEmpty, bool bContainDot)
		{
			if ((strNumber ?? "") == "")
			{
				return bIsEmpty;
			}
			if (bContainDot)
			{
				int num = strNumber.IndexOf('.');
				if (num >= 0)
				{
					num = strNumber.IndexOf('.', num + 1);
					if (num >= 0)
					{
						return false;
					}
				}
			}
			else if (strNumber.IndexOf('.') >= 0)
			{
				return false;
			}
			int num2 = strNumber.IndexOf('-');
			if (num2 >= 0)
			{
				num2 = strNumber.IndexOf('-', num2 + 1);
				if (num2 >= 0)
				{
					return false;
				}
			}
			char[] array = strNumber.ToCharArray();
			for (int i = 0; i <= array.GetUpperBound(0); i++)
			{
				if ((i != 0 || '-' != array[i]) && !char.IsDigit(array[i]))
				{
					if (array[i] != '.')
					{
						return false;
					}
					if (!bContainDot)
					{
						return false;
					}
				}
			}
			return (!bContainDot || strNumber.Replace('.', '\0').Length > 0) && strNumber.Replace('-', '\0').Length > 0;
		}

		private void CheckKeyIn(KeyPressEventArgs Key, bool bAllowDot)
		{
			if (char.IsControl(Key.KeyChar))
			{
				return;
			}
			if (char.IsDigit(Key.KeyChar))
			{
				return;
			}
			if (Key.KeyChar == '.')
			{
				if (!bAllowDot)
				{
					Key.KeyChar = '\0';
				}
				return;
			}
			if (Key.KeyChar == '-')
			{
				return;
			}
			Key.KeyChar = '\0';
		}

		private void NotePastText(DataGridViewTextBoxEditingControl txtFrom, ref LevelDimensionForm.PastText NoteTo)
		{
			if (txtFrom.Text == "" || txtFrom.Text == null)
			{
				txtFrom.Text = "";
			}
			NoteTo.strText = txtFrom.Text;
			NoteTo.nSelStart = txtFrom.SelectionStart;
			NoteTo.nSelLength = txtFrom.SelectionLength;
		}

        private void NotePastText(System.Windows.Forms.TextBox txtFrom, ref LevelDimensionForm.PastText NoteTo)
		{
			if (txtFrom.Text == "" || txtFrom.Text == null)
			{
				txtFrom.Text = "";
			}
			NoteTo.strText = txtFrom.Text;
			NoteTo.nSelStart = txtFrom.SelectionStart;
			NoteTo.nSelLength = txtFrom.SelectionLength;
		}

		private void RestoreText(DataGridViewTextBoxEditingControl txtRestoreTo, LevelDimensionForm.PastText TextFrom)
		{
			txtRestoreTo.Text = TextFrom.strText;
			txtRestoreTo.SelectionStart = TextFrom.nSelStart;
			txtRestoreTo.SelectionLength = TextFrom.nSelLength;
		}

		private void dataGridView1_CellMouseLeave(object sender, DataGridViewCellEventArgs e)
		{
			this.m_Previewer.Focus();
		}

		private void LevelDimensionForm_FormClosed(object sender, FormClosedEventArgs e)
		{
			if (this.m_hook != null)
			{
				this.m_hook.HookStop();
			}
			this.SendESC();
			this.m_bIsDlgClosed = true;
		}

		private void LevelDimensionForm_KeyDown(object sender, KeyEventArgs e)
		{
			try
			{
				Keys keyCode = e.KeyCode;
				if (keyCode == Keys.Escape)
				{
					base.Close();
				}
			}
			catch
			{
			}
		}

		private void chkAssociate_Click(object sender, EventArgs e)
		{
			this.InfoChange = true;
		}

		private void rbAutomatic_Click(object sender, EventArgs e)
		{
			this.InfoChange = true;
		}

		private void rbManual_Click(object sender, EventArgs e)
		{
			this.InfoChange = true;
		}

		private ExternalCommandData m_cmdData;

		private IntPtr m_iHandle;

		private Previewer m_Previewer;

		private MouseHook m_hook;

		private List<Level> m_lstAllLevels;

		private DimensionStyleParameter m_dimStyleParam = default(DimensionStyleParameter);

		private Dictionary<int, List<string>> m_dictFloorInfors;

		private DimensionStyle m_dimStyleGraph;

		private bool m_bInfoChange = true;

		private XYZ m_ptFloorLevelInsert = XYZ.Zero;

		private XYZ m_ptFloorNameInsert = XYZ.Zero;

		private XYZ m_ptLeft;

		private XYZ m_ptRight;

		private string m_strDimensionText = "";

		private List<Level> m_lstTableLevels = new List<Level>();

		public bool m_bIsLevelDlg;

		public bool m_bIsDlgClosed;

		private bool m_IsDlgShow;

		private LevelDimensionForm.PastText structPastText = default(LevelDimensionForm.PastText);

		private DataGridViewTextBoxEditingControl EditingControl = new DataGridViewTextBoxEditingControl();

		private struct PastText
		{
			public PastText(string strTxt, int nStart, int nLength)
			{
				this.strText = strTxt;
				this.nSelStart = nStart;
				this.nSelLength = nLength;
			}

			public string strText;

			public int nSelStart;

			public int nSelLength;
		}
	}
}
